package com.wiserp.rest.resource;

import org.restlet.resource.Get;
import org.restlet.resource.Put;
import org.restlet.resource.ResourceException;
import org.restlet.resource.ServerResource;

import com.wiserp.rest.helper.TransferHelper;
import com.wiserp.rest.model.OpResult;
import com.wiserp.rest.model.Transfer;

public class TransfersResource extends ServerResource{
	private TransferHelper helper;
	private String flowNo;
    protected void doInit() throws ResourceException {
    	Object flowNoParam = getRequestAttributes().get("flowNo");
    	if(flowNoParam!=null)
    		flowNo = (String)flowNoParam;	
	}
    
   
    @Get
    public Object findSomething(){
    	if(flowNo != null)
    		return helper.getByFlowNo(flowNo);
    	else
    		return helper.findUnpost();
    }
    
    @Put
    public OpResult uploadBill(Transfer data){
    	return helper.updateInfo(data);
    }

	public void setHelper(TransferHelper helper) {
		this.helper = helper;
	}
}
